package leetcode.stack_queue;

import java.util.PriorityQueue;

public class SmallestInfiniteSet {

    PriorityQueue<Integer> pq;
    int start ;

    public SmallestInfiniteSet() {
        pq = new PriorityQueue<>();
        start = 1;
    }

    public int popSmallest() {
        int minVal = 0;
        if (!pq.isEmpty()) minVal = pq.poll();
        else minVal = start++;
        return minVal;
    }

    public void addBack(int num) {
        if (num < start && !pq.contains(num))
            pq.offer(num);
    }


    public static void main(String[] args) {
        PriorityQueue<Integer> pq = new PriorityQueue<>();
        pq.offer(1);
        System.out.println(pq.contains(1));
    }

}
